package com.smedi.ismedi.authoritymanagement.core.infrastructure.config;

import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.sms.v20190711.SmsClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SmsClientConfig {
    @Value("${tencentCould.secretId}")
    private String secretId;

    @Value("${tencentCould.secretKey}")
    private String secretKey;

    public final static String endPoint = "sms.tencentcloudapi.com"; // 指定接入地域域名

    @Bean
    public SmsClient getSmsClient() {
        // 身份认证
        Credential cred = new Credential(secretId, secretKey);
        HttpProfile httpProfile = new HttpProfile();
        httpProfile.setEndpoint(endPoint);
        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setHttpProfile(httpProfile);
        
        // 生成客户端
        SmsClient client = new SmsClient(cred, "", clientProfile);
        return client;
    }
}
